package com.linuxgt.android.spapp.service;

import android.support.test.InstrumentationRegistry;

import org.junit.Before;
import org.junit.Test;

import java.util.Map;

import static org.junit.Assert.*;

/**
 * Created by liuteng on 2017/5/16.
 */
public class PreferencesServiceTest {
    private PreferencesService preferencesService;

    @Test
    public void save() throws Exception {
        String name = "liuteng";
        Integer age=12;
        preferencesService.save(name, age);
        Map<String, String> params = preferencesService.getPreferences();
        assertEquals(name,params.get("name"));
        assertEquals(age, Integer.valueOf(params.get("age")));
    }

    @Test
    public void getPreferences() throws Exception {
        Map<String, String> params = preferencesService.getPreferences();
        assertNotNull(params.get("age"));
    }

    @Before
    public void init() throws Exception {
        preferencesService = new PreferencesService(InstrumentationRegistry.getTargetContext());
    }

}